package com.shoujifeng.snowmusic.player;

import java.util.ArrayList;
import java.util.HashMap;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.content.Intent;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Button;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.geniuseoe2012.lazyloaderdemo.cache.ImageLoader;
import com.shoujifeng.snowmusic.adapter.GalleryAdapter;
import com.shoujifeng.snowmusic.adapter.LoaderAdapter;
import com.shoujifeng.snowmusic.player.http.GlobalValue;
import com.shoujifeng.snowmusic.player.http.PostAccess;
import com.shoujifeng.snowmusic.player.http.ServerAccess;
import com.shoujifeng.snowmusic.player.utils.HorizontalListView;
import com.shoujifeng.snowmusic.player.utils.LoadMask;
import com.shoujifeng.snowmusic.player.utils.MusicPlayer;
import com.shoujifeng.snowmusic.player.utils.TabHostAnim;

public class OnLineMusicActivity extends Activity implements
		SensorEventListener {
	private final int UPDATE_DATA = 0;
	private final int UPDATE_ONE = 1;
	private final int UPDATE_TWO = 2;
	private final int UPDATE_THREE = 3;
	private final int UPDATE_FOUR = 4;
	private final int UPDATE_FIVE = 5;
	private ArrayList<HashMap<String, Object>> mList;
	private ArrayList<HashMap<String, Object>> mMusicList; // 单曲推荐
	private ArrayList<HashMap<String, Object>> mAlbumList; // 专辑推荐
	private ArrayList<HashMap<String, Object>> mNewList;   //  最新单曲
	private ArrayList<HashMap<String, Object>> mPlayerList; //  歌手推荐
	private ArrayList<HashMap<String, Object>> mHotList;   //  热门歌单
	private ArrayList<HashMap<String, Object>> mAvdList; //  广告
	private ServerAccess serverAccess;
	private Thread accThread;
	private ImageLoader mImageLoader;
	private Gallery mGallery;
	private GalleryAdapter mGalleryAdapter;

	private HorizontalListView mListView;
	private LoaderAdapter mAdapter;

	private View imageView;
	// 翻页控件
	private ViewPager mViewPager;
	// 3个是底部显示当前状态点imageView
	private ImageView mPage0;
	private ImageView mPage1;
	private ImageView mPage2;

	// 推荐单曲
	private View musicLay;
	private TextView special_name1;
	private TextView countTxt1;
	private TextView playerName1;
	private TextView special_name2;
	private TextView countTxt2;
	private TextView playerName2;
	private TextView special_name3;
	private TextView countTxt3;
	private TextView playerName3;
	private TextView special_name4;
	private TextView countTxt4;
	private TextView playerName4;
	private TextView special_name5;
	private TextView countTxt5;
	private TextView playerName5;
	private ImageView imag1;
	private ImageView imag2;
	private ImageView imag3;
	private ImageView imag4;
	private ImageView imag5;

	private LinearLayout online_music_lay1;
	private LinearLayout online_music_lay2;
	private LinearLayout online_music_lay3;
	private LinearLayout online_music_lay4;
	private LinearLayout online_music_lay5;

	// 专辑推荐
	private View albumLay;
	private TextView lay1playerName1;
	private TextView lay1countTxt1;
	private TextView album1;
	private TextView lay1playerName2;
	private TextView lay1countTxt2;
	private TextView album2;
	private TextView lay1playerName3;
	private TextView lay1countTxt3;
	private TextView album3;
	private TextView lay1playerName4;
	private TextView lay1countTxt4;
	private TextView album4;
	private TextView lay1playerName5;
	private TextView lay1countTxt5;
	private TextView album5;
	private TextView lay1playerName6;
	private TextView lay1countTxt6;
	private TextView album6;

	private RelativeLayout lay1Layout1;
	private RelativeLayout lay1Layout2;
	private RelativeLayout lay1Layout3;
	private RelativeLayout lay1Layout4;
	private RelativeLayout lay1Layout5;
	private RelativeLayout lay1Layout6;

	private ImageView lay1Img1;
	private ImageView lay1Img2;
	private ImageView lay1Img3;
	private ImageView lay1Img4;
	private ImageView lay1Img5;
	private ImageView lay1Img6;

	// 最新单曲
	private View newLay;
	private TextView lay3special_name1;
	private TextView lay3countTxt1;
	private TextView lay3playerName1;

	private TextView lay3special_name2;
	private TextView lay3countTxt2;
	private TextView lay3playerName2;

	private TextView lay3special_name3;
	private TextView lay3countTxt3;
	private TextView lay3playerName3;

	private TextView lay3special_name4;
	private TextView lay3countTxt4;
	private TextView lay3playerName4;

	private TextView lay3special_name5;
	private TextView lay3countTxt5;
	private TextView lay3playerName5;

	private ImageView lay3Img1;
	private ImageView lay3Img2;
	private ImageView lay3Img3;
	private ImageView lay3Img4;
	private ImageView lay3Img5;

	private LinearLayout online_new_music_lay1;
	private LinearLayout online_new_music_lay2;
	private LinearLayout online_new_music_lay3;
	private LinearLayout online_new_music_lay4;
	private LinearLayout online_new_music_lay5;

	// 热门歌单
	private View hotLay;
	private TextView lay4MusicName1;
	private TextView lay4countTxt1;
	private TextView lay4MusicName2;
	private TextView lay4countTxt2;
	private TextView lay4MusicName3;
	private TextView lay4countTxt3;
	private TextView lay4MusicName4;
	private TextView lay4countTxt4;
	private TextView lay4MusicName5;
	private TextView lay4countTxt5;
	private TextView lay4MusicName6;
	private TextView lay4countTxt6;

	private ImageView lay4Img1;
	private ImageView lay4Img2;
	private ImageView lay4Img3;
	private ImageView lay4Img4;
	private ImageView lay4Img5;
	private ImageView lay4Img6;
	
	private RelativeLayout onlineFirstHotLay1;
	private RelativeLayout onlineFirstHotLay2;
	private RelativeLayout onlineFirstHotLay3;
	private RelativeLayout onlineFirstHotLay4;
	private RelativeLayout onlineFirstHotLay5;
	private RelativeLayout onlineFirstHotLay6;

	// 更多
	private Button singerMoreBtn;
	private Button musicMoreBtn;
	private Button specialMoreBtn;
	private Button newMusicMoreBtn;
	private Button hotMenueMoreBtn;

	private LoadMask mLoadMask;
	
	//顶部
	private LinearLayout linearLayout1;
	private LinearLayout linearLayout;
	private PostAccess mPostAccess;
	private 	HashMap<String, Object> map ;
	
	String keyPlayer[] = new String[] { ServerAccess.LISTENER,
			ServerAccess.SINGER, ServerAccess.ICON_URL,
			ServerAccess.INDEX ,ServerAccess.CODE};

	String keyMusci[] = new String[] { ServerAccess.MUSIC_NAME,
			ServerAccess.SINGER, ServerAccess.INDEX ,ServerAccess.LISTENER,ServerAccess.ICON_URL,
			ServerAccess.CODE,
			 ServerAccess.MUSIC_FILE,
			ServerAccess.ARTIST_ID};
	String keyAlbum[] = new String[] { ServerAccess.ALBUM,
			ServerAccess.SINGER, ServerAccess.LISTENER,
			ServerAccess.ICON_URL, ServerAccess.INDEX ,ServerAccess.CODE};

	String keyNew[] = new String[] { ServerAccess.MUSIC_NAME,
			ServerAccess.SINGER, ServerAccess.ICON_URL,
			ServerAccess.LISTENER, ServerAccess.INDEX ,
			ServerAccess.CODE,ServerAccess.MUSIC_FILE,ServerAccess.ARTIST_ID};
	
	String keyGruop[] = new String[] { ServerAccess.MUSIC,
			ServerAccess.CODE, ServerAccess.LISTENER,
			ServerAccess.ICON_URL, ServerAccess.INDEX };
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.online_music);
		initGlobalValue();
		init();
		initDate();
		mPostAccess = new PostAccess();
		mLoadMask = new LoadMask(this);
		mLoadMask.startLoad();
		accThread = new Thread(runnable);
		accThread.start();
	}

	private void init() {
		serverAccess = new ServerAccess(OnLineMusicActivity.this);
		mImageLoader = new ImageLoader(OnLineMusicActivity.this);
		
		// 推荐单曲
		musicLay = findViewById(R.id.onlinelay2);
		special_name1 = (TextView) musicLay.findViewById(R.id.special_name1);
		countTxt1 = (TextView) musicLay.findViewById(R.id.countTxt1);
		playerName1 = (TextView) musicLay.findViewById(R.id.playerName1);
		special_name2 = (TextView) musicLay.findViewById(R.id.special_name2);
		countTxt2 = (TextView) musicLay.findViewById(R.id.countTxt2);
		playerName2 = (TextView) musicLay.findViewById(R.id.playerName2);
		special_name3 = (TextView) musicLay.findViewById(R.id.special_name3);
		countTxt3 = (TextView) musicLay.findViewById(R.id.countTxt3);
		playerName3 = (TextView) musicLay.findViewById(R.id.playerName3);
		special_name4 = (TextView) musicLay.findViewById(R.id.special_name4);
		countTxt4 = (TextView) musicLay.findViewById(R.id.countTxt4);
		playerName4 = (TextView) musicLay.findViewById(R.id.playerName4);
		special_name5 = (TextView) musicLay.findViewById(R.id.special_name5);
		countTxt5 = (TextView) musicLay.findViewById(R.id.countTxt5);
		playerName5 = (TextView) musicLay.findViewById(R.id.playerName5);
		imag1 = (ImageView) musicLay.findViewById(R.id.imag1);
		imag2 = (ImageView) musicLay.findViewById(R.id.imag2);
		imag3 = (ImageView) musicLay.findViewById(R.id.imag3);
		imag4 = (ImageView) musicLay.findViewById(R.id.imag4);
		imag5 = (ImageView) musicLay.findViewById(R.id.imag5);

		online_music_lay1 = (LinearLayout) findViewById(R.id.online_music_lay1);
		online_music_lay2 = (LinearLayout) findViewById(R.id.online_music_lay2);
		online_music_lay3 = (LinearLayout) findViewById(R.id.online_music_lay3);
		online_music_lay4 = (LinearLayout) findViewById(R.id.online_music_lay4);
		online_music_lay5 = (LinearLayout) findViewById(R.id.online_music_lay5);
		online_music_lay1.setOnClickListener(onClickListener);
		online_music_lay2.setOnClickListener(onClickListener);
		online_music_lay3.setOnClickListener(onClickListener);
		online_music_lay4.setOnClickListener(onClickListener);
		online_music_lay5.setOnClickListener(onClickListener);

		// 专辑推荐
		albumLay = findViewById(R.id.onlinelay1);
		lay1playerName1 = (TextView) albumLay
				.findViewById(R.id.lay1playerName1);
		lay1countTxt1 = (TextView) albumLay.findViewById(R.id.lay1countTxt1);
		album1 = (TextView) albumLay.findViewById(R.id.album1);

		lay1playerName2 = (TextView) albumLay
				.findViewById(R.id.lay1playerName2);
		lay1countTxt2 = (TextView) albumLay.findViewById(R.id.lay1countTxt2);
		album2 = (TextView) albumLay.findViewById(R.id.album2);

		lay1playerName3 = (TextView) albumLay
				.findViewById(R.id.lay1playerName3);
		lay1countTxt3 = (TextView) albumLay.findViewById(R.id.lay1countTxt3);
		album3 = (TextView) albumLay.findViewById(R.id.album3);

		lay1playerName4 = (TextView) albumLay
				.findViewById(R.id.lay1playerName4);
		lay1countTxt4 = (TextView) albumLay.findViewById(R.id.lay1countTxt4);
		album4 = (TextView) albumLay.findViewById(R.id.album4);

		lay1playerName5 = (TextView) albumLay
				.findViewById(R.id.lay1playerName5);
		lay1countTxt5 = (TextView) albumLay.findViewById(R.id.lay1countTxt5);
		album5 = (TextView) albumLay.findViewById(R.id.album5);

		lay1playerName6 = (TextView) albumLay
				.findViewById(R.id.lay1playerName6);
		lay1countTxt6 = (TextView) albumLay.findViewById(R.id.lay1countTxt6);
		album6 = (TextView) albumLay.findViewById(R.id.album6);

		lay1Img1 = (ImageView) albumLay.findViewById(R.id.lay1Img1);
		lay1Img2 = (ImageView) albumLay.findViewById(R.id.lay1Img2);
		lay1Img3 = (ImageView) albumLay.findViewById(R.id.lay1Img3);
		lay1Img4 = (ImageView) albumLay.findViewById(R.id.lay1Img4);
		lay1Img5 = (ImageView) albumLay.findViewById(R.id.lay1Img5);
		lay1Img6 = (ImageView) albumLay.findViewById(R.id.lay1Img6);

		lay1Layout1 = (RelativeLayout) albumLay.findViewById(R.id.lay1Layout1);
		lay1Layout2 = (RelativeLayout) albumLay.findViewById(R.id.lay1Layout2);
		lay1Layout3 = (RelativeLayout) albumLay.findViewById(R.id.lay1Layout3);
		lay1Layout4 = (RelativeLayout) albumLay.findViewById(R.id.lay1Layout4);
		lay1Layout5 = (RelativeLayout) albumLay.findViewById(R.id.lay1Layout5);
		lay1Layout6 = (RelativeLayout) albumLay.findViewById(R.id.lay1Layout6);
		lay1Layout1.setOnClickListener(onClickListener);
		lay1Layout2.setOnClickListener(onClickListener);
		lay1Layout3.setOnClickListener(onClickListener);
		lay1Layout4.setOnClickListener(onClickListener);
		lay1Layout5.setOnClickListener(onClickListener);
		lay1Layout6.setOnClickListener(onClickListener);

		// 最新单曲
		newLay = findViewById(R.id.onlinelay3);
		lay3special_name1 = (TextView) newLay
				.findViewById(R.id.lay3special_name1);
		lay3countTxt1 = (TextView) newLay.findViewById(R.id.lay3countTxt1);
		lay3playerName1 = (TextView) newLay.findViewById(R.id.lay3playerName1);

		lay3special_name2 = (TextView) newLay
				.findViewById(R.id.lay3special_name2);
		lay3countTxt2 = (TextView) newLay.findViewById(R.id.lay3countTxt2);
		lay3playerName2 = (TextView) newLay.findViewById(R.id.lay3playerName2);

		lay3special_name3 = (TextView) newLay
				.findViewById(R.id.lay3special_name3);
		lay3countTxt3 = (TextView) newLay.findViewById(R.id.lay3countTxt3);
		lay3playerName3 = (TextView) newLay.findViewById(R.id.lay3playerName3);

		lay3special_name4 = (TextView) newLay
				.findViewById(R.id.lay3special_name4);
		lay3countTxt4 = (TextView) newLay.findViewById(R.id.lay3countTxt4);
		lay3playerName4 = (TextView) newLay.findViewById(R.id.lay3playerName4);

		lay3special_name5 = (TextView) newLay
				.findViewById(R.id.lay3special_name5);
		lay3countTxt5 = (TextView) newLay.findViewById(R.id.lay3countTxt5);
		lay3playerName5 = (TextView) newLay.findViewById(R.id.lay3playerName5);
		lay3Img1 = (ImageView) newLay.findViewById(R.id.lay3Img1);
		lay3Img2 = (ImageView) newLay.findViewById(R.id.lay3Img2);
		lay3Img3 = (ImageView) newLay.findViewById(R.id.lay3Img3);
		lay3Img4 = (ImageView) newLay.findViewById(R.id.lay3Img4);
		lay3Img5 = (ImageView) newLay.findViewById(R.id.lay3Img5);

		online_new_music_lay1 = (LinearLayout) findViewById(R.id.online_new_music_lay1);
		online_new_music_lay2 = (LinearLayout) findViewById(R.id.online_new_music_lay2);
		online_new_music_lay3 = (LinearLayout) findViewById(R.id.online_new_music_lay3);
		online_new_music_lay4 = (LinearLayout) findViewById(R.id.online_new_music_lay4);
		online_new_music_lay5 = (LinearLayout) findViewById(R.id.online_new_music_lay5);
		online_new_music_lay1.setOnClickListener(onClickListener);
		online_new_music_lay2.setOnClickListener(onClickListener);
		online_new_music_lay3.setOnClickListener(onClickListener);
		online_new_music_lay4.setOnClickListener(onClickListener);
		online_new_music_lay5.setOnClickListener(onClickListener);

		// 热门歌单
		hotLay = findViewById(R.id.onlinelay4);
		lay4MusicName1 = (TextView) hotLay.findViewById(R.id.lay4MusicName1);
		lay4countTxt1 = (TextView) hotLay.findViewById(R.id.lay4countTxt1);
		lay4MusicName2 = (TextView) hotLay.findViewById(R.id.lay4MusicName2);
		lay4countTxt2 = (TextView) hotLay.findViewById(R.id.lay4countTxt2);
		lay4MusicName3 = (TextView) hotLay.findViewById(R.id.lay4MusicName3);
		lay4countTxt3 = (TextView) hotLay.findViewById(R.id.lay4countTxt3);
		lay4MusicName4 = (TextView) hotLay.findViewById(R.id.lay4MusicName4);
		lay4countTxt4 = (TextView) hotLay.findViewById(R.id.lay4countTxt4);
		lay4MusicName5 = (TextView) hotLay.findViewById(R.id.lay4MusicName5);
		lay4countTxt5 = (TextView) hotLay.findViewById(R.id.lay4countTxt5);
		lay4MusicName6 = (TextView) hotLay.findViewById(R.id.lay4MusicName6);
		lay4countTxt6 = (TextView) hotLay.findViewById(R.id.lay4countTxt6);

		lay4Img1 = (ImageView) hotLay.findViewById(R.id.lay4Img1);
		lay4Img2 = (ImageView) hotLay.findViewById(R.id.lay4Img2);
		lay4Img3 = (ImageView) hotLay.findViewById(R.id.lay4Img3);
		lay4Img4 = (ImageView) hotLay.findViewById(R.id.lay4Img4);
		lay4Img5 = (ImageView) hotLay.findViewById(R.id.lay4Img5);
		lay4Img6 = (ImageView) hotLay.findViewById(R.id.lay4Img6);
		
		onlineFirstHotLay1 = (RelativeLayout) hotLay.findViewById(R.id.onlineFirstHotLay1);
		onlineFirstHotLay2 = (RelativeLayout) hotLay.findViewById(R.id.onlineFirstHotLay2);
		onlineFirstHotLay3 = (RelativeLayout) hotLay.findViewById(R.id.onlineFirstHotLay3);
		onlineFirstHotLay4 = (RelativeLayout) hotLay.findViewById(R.id.onlineFirstHotLay4);
		onlineFirstHotLay5 = (RelativeLayout) hotLay.findViewById(R.id.onlineFirstHotLay5);
		onlineFirstHotLay6 = (RelativeLayout) hotLay.findViewById(R.id.onlineFirstHotLay6);
		onlineFirstHotLay1.setOnClickListener(onClickListener);
		onlineFirstHotLay2.setOnClickListener(onClickListener);
		onlineFirstHotLay3.setOnClickListener(onClickListener);
		onlineFirstHotLay4.setOnClickListener(onClickListener);
		onlineFirstHotLay5.setOnClickListener(onClickListener);
		onlineFirstHotLay6.setOnClickListener(onClickListener);

		// 更多
		singerMoreBtn = (Button) findViewById(R.id.online_singer_more_btn);
		singerMoreBtn.setOnClickListener(onClickListener);
		specialMoreBtn = (Button) findViewById(R.id.online_special_music_more_btn);
		specialMoreBtn.setOnClickListener(onClickListener);
		musicMoreBtn = (Button) findViewById(R.id.online_music_more_btn);
		musicMoreBtn.setOnClickListener(onClickListener);
		newMusicMoreBtn = (Button) findViewById(R.id.online_new_music_more_btn);
		newMusicMoreBtn.setOnClickListener(onClickListener);
		hotMenueMoreBtn = (Button) findViewById(R.id.online_hot_music_more_btn);
		hotMenueMoreBtn.setOnClickListener(onClickListener);

		imageView = findViewById(R.id.image_view);
		

		

		mListView = (HorizontalListView) findViewById(R.id.listview);

		mListView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				// TODO Auto-generated method stub
				HashMap<String, Object> map = new HashMap<String, Object>();
				map = mPlayerList.get(arg2);
				Intent intent = new Intent(OnLineMusicActivity.this,
						OnlinePlayerContentListActivity.class);
				intent.putExtra(ServerAccess.SINGER,
						map.get(ServerAccess.SINGER).toString());
				intent.putExtra(ServerAccess.INDEX, map.get(ServerAccess.INDEX)
						.toString());
				startActivity(intent);
				
				TabHostAnim.set(R.anim.right_in, R.anim.no_move);
			}
		});

	}
	private void creatImg(){
		linearLayout1 = (LinearLayout) imageView.findViewById(R.id.linearLayout1);
		for(int i = 0;i<mAvdList.size();i++){
			linearLayout = new LinearLayout(OnLineMusicActivity.this);
			ImageView image = new ImageView(OnLineMusicActivity.this);
			linearLayout.setPadding(5, 5, 5, 5);	
			if(i==0){
				image.setBackgroundResource(R.drawable.no);
			}
			else{
				image.setBackgroundResource(R.drawable.on);
			}
			linearLayout.addView(image);
			
			linearLayout1.addView(linearLayout);
		}
	}
	// 设定画廊的显示方式和内容
		public void prepare() {
			
			mGallery = (Gallery) imageView.findViewById(R.id.home_gallery);
			mGalleryAdapter = new GalleryAdapter(this,mAvdList);
			mGallery.setAdapter(mGalleryAdapter);
			mGallery.setOnItemClickListener(new OnItemClickListener() {

				@Override
				public void onItemClick(AdapterView<?> parent, View view,
						int position, long id) {
					Intent intent = new Intent(OnLineMusicActivity.this,OnlineAdvContentActivity.class);
					intent.putExtra(ServerAccess.ID, mAvdList.get(position).get(ServerAccess.ID).toString());
					startActivity(intent);
					
					TabHostAnim.set(R.anim.right_in, R.anim.no_move);
				}

			});
			mGallery.setOnItemSelectedListener(new OnItemSelectedListener() {

				@Override
				public void onItemSelected(AdapterView<?> arg0, View arg1,
						int arg2, long arg3) {
					//mMyView.setSeletion(arg2);
					linearLayout.removeAllViews();
					linearLayout1.removeAllViews();
						for(int i = 0;i<mAvdList.size();i++){
							linearLayout = new LinearLayout(OnLineMusicActivity.this);
							ImageView image = new ImageView(OnLineMusicActivity.this);
							linearLayout.setPadding(5, 5, 5, 5);	
							if(i==arg2){
								image.setBackgroundResource(R.drawable.no);
							}
							else{
								image.setBackgroundResource(R.drawable.on);
							}
							linearLayout.addView(image);
							
							linearLayout1.addView(linearLayout);
						}
					
				}

				@Override
				public void onNothingSelected(AdapterView<?> arg0) {

				}
			});
		}
	private void initDate() {
		mPlayerList = new ArrayList<HashMap<String, Object>>();
		String keys[] = new String[] { ServerAccess.LISTENER,
				ServerAccess.SINGER };
		mAdapter = new LoaderAdapter(this, mPlayerList, new int[] { R.id.count,
				R.id.playerName }, keys,
				new String[] { ServerAccess.ICON_URL },
				new int[] { R.id.face }, R.drawable.icon_singer_default,
				R.layout.horizontall_list);
		mListView.setAdapter(mAdapter);
	}

	private OnClickListener onClickListener = new OnClickListener() {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			switch (v.getId()) {
			case R.id.lay1Layout1: {
				HashMap<String, Object> map = new HashMap<String, Object>();
				map = mAlbumList.get(0);
				Intent intent = new Intent(OnLineMusicActivity.this,
						OnlineSpecialContentActivity.class);
				intent.putExtra(ServerAccess.INDEX, map.get(ServerAccess.INDEX)
						.toString());
				intent.putExtra(ServerAccess.SINGER,
						map.get(ServerAccess.SINGER).toString());
				intent.putExtra(ServerAccess.ALBUM, map.get(ServerAccess.ALBUM)
						.toString());
				startActivity(intent);
				
				TabHostAnim.set(R.anim.right_in, R.anim.no_move);
			}
				break;
			case R.id.lay1Layout2: {
				HashMap<String, Object> map = new HashMap<String, Object>();
				map = mAlbumList.get(1);
				Intent intent = new Intent(OnLineMusicActivity.this,
						OnlineSpecialContentActivity.class);
				intent.putExtra(ServerAccess.INDEX, map.get(ServerAccess.INDEX)
						.toString());
				intent.putExtra(ServerAccess.SINGER,
						map.get(ServerAccess.SINGER).toString());
				intent.putExtra(ServerAccess.ALBUM, map.get(ServerAccess.ALBUM)
						.toString());
				startActivity(intent);
				
				TabHostAnim.set(R.anim.right_in, R.anim.no_move);
			}
				break;
			case R.id.lay1Layout3: {
				HashMap<String, Object> map = new HashMap<String, Object>();
				map = mAlbumList.get(2);
				Intent intent = new Intent(OnLineMusicActivity.this,
						OnlineSpecialContentActivity.class);
				intent.putExtra(ServerAccess.INDEX, map.get(ServerAccess.INDEX)
						.toString());
				intent.putExtra(ServerAccess.SINGER,
						map.get(ServerAccess.SINGER).toString());
				intent.putExtra(ServerAccess.ALBUM, map.get(ServerAccess.ALBUM)
						.toString());
				startActivity(intent);
				
				TabHostAnim.set(R.anim.right_in, R.anim.no_move);
			}
				break;
			case R.id.lay1Layout4: {
				HashMap<String, Object> map = new HashMap<String, Object>();
				map = mAlbumList.get(3);
				Intent intent = new Intent(OnLineMusicActivity.this,
						OnlineSpecialContentActivity.class);
				intent.putExtra(ServerAccess.INDEX, map.get(ServerAccess.INDEX)
						.toString());
				intent.putExtra(ServerAccess.SINGER,
						map.get(ServerAccess.SINGER).toString());
				intent.putExtra(ServerAccess.ALBUM, map.get(ServerAccess.ALBUM)
						.toString());
				startActivity(intent);
				
				TabHostAnim.set(R.anim.right_in, R.anim.no_move);
			}
				break;
			case R.id.lay1Layout5: {
				HashMap<String, Object> map = new HashMap<String, Object>();
				map = mAlbumList.get(4);
				Intent intent = new Intent(OnLineMusicActivity.this,
						OnlineSpecialContentActivity.class);
				intent.putExtra(ServerAccess.INDEX, map.get(ServerAccess.INDEX)
						.toString());
				intent.putExtra(ServerAccess.SINGER,
						map.get(ServerAccess.SINGER).toString());
				intent.putExtra(ServerAccess.ALBUM, map.get(ServerAccess.ALBUM)
						.toString());
				startActivity(intent);
				
				TabHostAnim.set(R.anim.right_in, R.anim.no_move);
			}
				break;
			case R.id.lay1Layout6: {
				HashMap<String, Object> map = new HashMap<String, Object>();
				map = mAlbumList.get(5);
				Intent intent = new Intent(OnLineMusicActivity.this,
						OnlineSpecialContentActivity.class);
				intent.putExtra(ServerAccess.INDEX, map.get(ServerAccess.INDEX)
						.toString());
				intent.putExtra(ServerAccess.SINGER,
						map.get(ServerAccess.SINGER).toString());
				intent.putExtra(ServerAccess.ALBUM, map.get(ServerAccess.ALBUM)
						.toString());
				startActivity(intent);
				
				TabHostAnim.set(R.anim.right_in, R.anim.no_move);
			}
				break;
			case R.id.online_singer_more_btn: {
				Intent intent = new Intent(OnLineMusicActivity.this,
						OnlineSingerMoreActivity.class);
				startActivity(intent);
				
				TabHostAnim.set(R.anim.right_in, R.anim.no_move);
			}
				break;
			case R.id.online_music_more_btn: {
				Intent intent = new Intent(OnLineMusicActivity.this,
						OnlineMusicMoreActivity.class);
				startActivity(intent);
				
				TabHostAnim.set(R.anim.right_in, R.anim.no_move);
			}
				break;
			case R.id.online_special_music_more_btn: {
				Intent intent = new Intent(OnLineMusicActivity.this,
						OnlineSpecialMoreActivity.class);
				startActivity(intent);
				
				TabHostAnim.set(R.anim.right_in, R.anim.no_move);
			}
				break;
			case R.id.online_new_music_more_btn: {
				Intent intent = new Intent(OnLineMusicActivity.this,
						OnlineNewMusicMoreActivity.class);
				startActivity(intent);
				
				TabHostAnim.set(R.anim.right_in, R.anim.no_move);
			}
				break;
			case R.id.online_hot_music_more_btn: {
				Intent intent = new Intent(OnLineMusicActivity.this,
						OnlineNewMusicMenuMoreActivity.class);
				startActivity(intent);
				
				TabHostAnim.set(R.anim.right_in, R.anim.no_move);
			}
				break;
			case R.id.online_music_lay1: {
				Intent intent = new Intent(OnLineMusicActivity.this,
						MusicPlayerActivity.class);
				MusicPlayerActivity.mOlineMusicList = mMusicList;
				MusicPlayer.position = 0;
				 MusicPlayer.MUSCI_MSG =1;
				MusicPlayerActivity.isOnline = true;
				startActivity(intent);
				
				TabHostAnim.set(R.anim.bottom_in, android.R.anim.fade_out);
			}
				break;
			case R.id.online_music_lay2: {
				Intent intent = new Intent(OnLineMusicActivity.this,
						MusicPlayerActivity.class);
				MusicPlayerActivity.mOlineMusicList = mMusicList;
				MusicPlayer.position = 1;
				 MusicPlayer.MUSCI_MSG =1;
				MusicPlayerActivity.isOnline = true;
				startActivity(intent);
				
				TabHostAnim.set(R.anim.bottom_in, android.R.anim.fade_out);
			}
				break;
			case R.id.online_music_lay3: {
				Intent intent = new Intent(OnLineMusicActivity.this,
						MusicPlayerActivity.class);
				MusicPlayerActivity.mOlineMusicList = mMusicList;
				MusicPlayer.position = 2;
				 MusicPlayer.MUSCI_MSG =1;
				MusicPlayerActivity.isOnline = true;
				startActivity(intent);
				
				TabHostAnim.set(R.anim.bottom_in, android.R.anim.fade_out);
			}
				break;
			case R.id.online_music_lay4: {
				Intent intent = new Intent(OnLineMusicActivity.this,
						MusicPlayerActivity.class);
				MusicPlayerActivity.mOlineMusicList = mMusicList;
				MusicPlayer.position = 3;
				 MusicPlayer.MUSCI_MSG =1;
				MusicPlayerActivity.isOnline = true;
				startActivity(intent);
				
				TabHostAnim.set(R.anim.bottom_in, android.R.anim.fade_out);
			}
				break;
			case R.id.online_music_lay5: {
				Intent intent = new Intent(OnLineMusicActivity.this,
						MusicPlayerActivity.class);
				MusicPlayerActivity.mOlineMusicList = mMusicList;
				MusicPlayer.position = 4;
				 MusicPlayer.MUSCI_MSG =1;
				MusicPlayerActivity.isOnline = true;
				startActivity(intent);
				
				TabHostAnim.set(R.anim.bottom_in, android.R.anim.fade_out);
			}
				break;
			case R.id.online_new_music_lay1: {
				Intent intent = new Intent(OnLineMusicActivity.this,
						MusicPlayerActivity.class);
				MusicPlayerActivity.mOlineMusicList = mNewList;
				 MusicPlayer.MUSCI_MSG =1;
				MusicPlayer.position = 0;
				MusicPlayerActivity.isOnline = true;
				startActivity(intent);
				
				TabHostAnim.set(R.anim.bottom_in, android.R.anim.fade_out);
			}
				break;
			case R.id.online_new_music_lay2: {
				Intent intent = new Intent(OnLineMusicActivity.this,
						MusicPlayerActivity.class);
				MusicPlayerActivity.mOlineMusicList = mNewList;
				 MusicPlayer.MUSCI_MSG =1;
				MusicPlayer.position = 1;
				MusicPlayerActivity.isOnline = true;
				startActivity(intent);
				
				TabHostAnim.set(R.anim.bottom_in, android.R.anim.fade_out);
			}
				break;
			case R.id.online_new_music_lay3: {
				Intent intent = new Intent(OnLineMusicActivity.this,
						MusicPlayerActivity.class);
				MusicPlayerActivity.mOlineMusicList = mNewList;
				 MusicPlayer.MUSCI_MSG =1;
				MusicPlayer.position = 2;
				MusicPlayerActivity.isOnline = true;
				startActivity(intent);
				
				TabHostAnim.set(R.anim.bottom_in, android.R.anim.fade_out);
			}
				break;
			case R.id.online_new_music_lay4: {
				Intent intent = new Intent(OnLineMusicActivity.this,
						MusicPlayerActivity.class);
				MusicPlayerActivity.mOlineMusicList = mNewList;
				 MusicPlayer.MUSCI_MSG =1;
				MusicPlayer.position = 3;
				MusicPlayerActivity.isOnline = true;
				startActivity(intent);
				
				TabHostAnim.set(R.anim.bottom_in, android.R.anim.fade_out);
			}
				break;
			case R.id.online_new_music_lay5: {
				Intent intent = new Intent(OnLineMusicActivity.this,
						MusicPlayerActivity.class);
				MusicPlayerActivity.mOlineMusicList = mNewList;
				 MusicPlayer.MUSCI_MSG =1;
				MusicPlayer.position = 4;
				MusicPlayerActivity.isOnline = true;
				startActivity(intent);
				
				TabHostAnim.set(R.anim.bottom_in, android.R.anim.fade_out);
			}
				break;
			case R.id.onlineFirstHotLay1:{
				Intent intent = new Intent(OnLineMusicActivity.this,OnlineHotMenuContentActivity.class);
				HashMap<String, Object> map = new HashMap<String, Object>();
				map = mHotList.get(0);
				intent.putExtra(ServerAccess.INDEX, map.get(ServerAccess.INDEX).toString());
				intent.putExtra(ServerAccess.MUSIC, map.get(ServerAccess.MUSIC).toString());
				startActivity(intent);
				
				TabHostAnim.set(R.anim.right_in, R.anim.no_move);
			}	
			break;
			case R.id.onlineFirstHotLay2:{
				Intent intent = new Intent(OnLineMusicActivity.this,OnlineHotMenuContentActivity.class);
				HashMap<String, Object> map = new HashMap<String, Object>();
				map = mHotList.get(1);
				intent.putExtra(ServerAccess.INDEX, map.get(ServerAccess.INDEX).toString());
				intent.putExtra(ServerAccess.MUSIC, map.get(ServerAccess.MUSIC).toString());
				startActivity(intent);
				
				TabHostAnim.set(R.anim.right_in, R.anim.no_move);
			}	
			break;
			case R.id.onlineFirstHotLay3:{
				Intent intent = new Intent(OnLineMusicActivity.this,OnlineHotMenuContentActivity.class);
				HashMap<String, Object> map = new HashMap<String, Object>();
				map = mHotList.get(2);
				intent.putExtra(ServerAccess.INDEX, map.get(ServerAccess.INDEX).toString());
				intent.putExtra(ServerAccess.MUSIC, map.get(ServerAccess.MUSIC).toString());
				startActivity(intent);
				
				TabHostAnim.set(R.anim.right_in, R.anim.no_move);
			}	
			break;
			case R.id.onlineFirstHotLay4:{
				Intent intent = new Intent(OnLineMusicActivity.this,OnlineHotMenuContentActivity.class);
				HashMap<String, Object> map = new HashMap<String, Object>();
				map = mHotList.get(3);
				intent.putExtra(ServerAccess.INDEX, map.get(ServerAccess.INDEX).toString());
				intent.putExtra(ServerAccess.MUSIC, map.get(ServerAccess.MUSIC).toString());
				startActivity(intent);
				
				TabHostAnim.set(R.anim.right_in, R.anim.no_move);
			}	
			break;
			case R.id.onlineFirstHotLay5:{
				Intent intent = new Intent(OnLineMusicActivity.this,OnlineHotMenuContentActivity.class);
				HashMap<String, Object> map = new HashMap<String, Object>();
				map = mHotList.get(4);
				intent.putExtra(ServerAccess.INDEX, map.get(ServerAccess.INDEX).toString());
				intent.putExtra(ServerAccess.MUSIC, map.get(ServerAccess.MUSIC).toString());
				startActivity(intent);
				
				TabHostAnim.set(R.anim.right_in, R.anim.no_move);
			}	
			break;
			case R.id.onlineFirstHotLay6:{
				Intent intent = new Intent(OnLineMusicActivity.this,OnlineHotMenuContentActivity.class);
				HashMap<String, Object> map = new HashMap<String, Object>();
				map = mHotList.get(5);
				intent.putExtra(ServerAccess.INDEX, map.get(ServerAccess.INDEX).toString());
				intent.putExtra(ServerAccess.MUSIC, map.get(ServerAccess.MUSIC).toString());
				startActivity(intent);
				
				TabHostAnim.set(R.anim.right_in, R.anim.no_move);
			}	
			break;
				
			default:
				break;
			}
		}
	};

	public class MyOnPageChangeListener implements OnPageChangeListener {

		public void onPageSelected(int page) {
			// 翻页时当前page,改变当前状态园点图片
			switch (page) {
			case 0:
				mPage0.setImageDrawable(getResources().getDrawable(
						R.drawable.on));
				mPage1.setImageDrawable(getResources().getDrawable(
						R.drawable.no));
				mPage2.setImageDrawable(getResources().getDrawable(
						R.drawable.no));
				break;
			case 1:
				mPage0.setImageDrawable(getResources().getDrawable(
						R.drawable.no));
				mPage1.setImageDrawable(getResources().getDrawable(
						R.drawable.on));
				mPage2.setImageDrawable(getResources().getDrawable(
						R.drawable.no));
				break;
			case 2:
				mPage0.setImageDrawable(getResources().getDrawable(
						R.drawable.no));
				mPage1.setImageDrawable(getResources().getDrawable(
						R.drawable.no));
				mPage2.setImageDrawable(getResources().getDrawable(
						R.drawable.on));
				break;

			}
		}

		@Override
		public void onPageScrollStateChanged(int arg0) {
			// TODO Auto-generated method stub

		}

		@Override
		public void onPageScrolled(int arg0, float arg1, int arg2) {
			// TODO Auto-generated method stub

		}

	}

	@Override
	public void onAccuracyChanged(Sensor arg0, int arg1) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onSensorChanged(SensorEvent arg0) {
		// TODO Auto-generated method stub

	}

	private void initGlobalValue() {
		GlobalValue.initSDAddr();

		GlobalValue.addUrl(ServerAccess.MAIN,
				"http://www.snowmusic.com.cn/mobile_api/main.php");
		GlobalValue.addUrl(ServerAccess.ADV_LIST,
				"http://www.snowmusic.com.cn/mobile_api/adv_list.php");
	}

	protected Handler handler = new Handler() {
		@SuppressWarnings("unchecked")
		@Override
		public void handleMessage(Message msg) {

			switch (msg.what) {
			case UPDATE_FIVE:{
				creatImg();
				prepare();
			}
			break;
			
			case UPDATE_DATA: {
				mLoadMask.stopLoad();
				map = new HashMap<String, Object>();
				map = mMusicList.get(0);

				special_name1.setText(map.get(ServerAccess.MUSIC_NAME)
						.toString());
				countTxt1.setText(map.get(ServerAccess.LISTENER).toString());
				playerName1.setText(map.get(ServerAccess.SINGER).toString());
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), imag1, false,
						R.drawable.icon_music_default);
				map = mMusicList.get(1);
				special_name2.setText(map.get(ServerAccess.MUSIC_NAME)
						.toString());
				countTxt2.setText(map.get(ServerAccess.LISTENER).toString());
				playerName2.setText(map.get(ServerAccess.SINGER).toString());
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), imag2, false,
						R.drawable.icon_music_default);
				map = mMusicList.get(2);
				special_name3.setText(map.get(ServerAccess.MUSIC_NAME)
						.toString());
				countTxt3.setText(map.get(ServerAccess.LISTENER).toString());
				playerName3.setText(map.get(ServerAccess.SINGER).toString());
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), imag3, false,
						R.drawable.icon_music_default);
				map = mMusicList.get(3);
				special_name4.setText(map.get(ServerAccess.MUSIC_NAME)
						.toString());
				countTxt4.setText(map.get(ServerAccess.LISTENER).toString());
				playerName4.setText(map.get(ServerAccess.SINGER).toString());
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), imag4, false,
						R.drawable.icon_music_default);
				map = mMusicList.get(4);
				special_name5.setText(map.get(ServerAccess.MUSIC_NAME)
						.toString());
				countTxt5.setText(map.get(ServerAccess.LISTENER).toString());
				playerName5.setText(map.get(ServerAccess.SINGER).toString());
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), imag5, false,
						R.drawable.icon_music_default);
			
				map = new HashMap<String, Object>();
				map = mAlbumList.get(0);
				lay1playerName1
						.setText(map.get(ServerAccess.SINGER).toString());
				lay1countTxt1
						.setText(map.get(ServerAccess.LISTENER).toString());
				album1.setText("<<" + map.get(ServerAccess.ALBUM).toString()
						+ ">>");
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), lay1Img1, false,
						R.drawable.icon_album_default);

				map = mAlbumList.get(1);
				lay1playerName2
						.setText(map.get(ServerAccess.SINGER).toString());
				lay1countTxt2
						.setText(map.get(ServerAccess.LISTENER).toString());
				album2.setText("<<" + map.get(ServerAccess.ALBUM).toString()
						+ ">>");
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), lay1Img2, false,
						R.drawable.icon_album_default);
				map = mAlbumList.get(2);
				lay1playerName3
						.setText(map.get(ServerAccess.SINGER).toString());
				lay1countTxt3
						.setText(map.get(ServerAccess.LISTENER).toString());
				album3.setText("<<" + map.get(ServerAccess.ALBUM).toString()
						+ ">>");
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), lay1Img3, false,
						R.drawable.icon_album_default);
				map = mAlbumList.get(3);
				lay1playerName4
						.setText(map.get(ServerAccess.SINGER).toString());
				lay1countTxt4
						.setText(map.get(ServerAccess.LISTENER).toString());
				album4.setText("<<" + map.get(ServerAccess.ALBUM).toString()
						+ ">>");
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), lay1Img4, false,
						R.drawable.icon_album_default);
				map = mAlbumList.get(4);
				lay1playerName5
						.setText(map.get(ServerAccess.SINGER).toString());
				lay1countTxt5
						.setText(map.get(ServerAccess.LISTENER).toString());
				album5.setText("<<" + map.get(ServerAccess.ALBUM).toString()
						+ ">>");
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), lay1Img5, false,
						R.drawable.icon_album_default);
				map = mAlbumList.get(5);
				lay1playerName6
						.setText(map.get(ServerAccess.SINGER).toString());
				lay1countTxt6
						.setText(map.get(ServerAccess.LISTENER).toString());
				album6.setText("<<" + map.get(ServerAccess.ALBUM).toString()
						+ ">>");
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), lay1Img6, false,
						R.drawable.icon_album_default);
			
				map = new HashMap<String, Object>();
				map = mNewList.get(0);
				lay3special_name1.setText(map.get(ServerAccess.MUSIC_NAME)
						.toString());
				lay3countTxt1
						.setText(map.get(ServerAccess.LISTENER).toString());
				lay3playerName1
						.setText(map.get(ServerAccess.SINGER).toString());

				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), lay3Img1, false,
						R.drawable.icon_music_default);
				map = mNewList.get(1);
				lay3special_name2.setText(map.get(ServerAccess.MUSIC_NAME)
						.toString());
				lay3countTxt2
						.setText(map.get(ServerAccess.LISTENER).toString());
				lay3playerName2
						.setText(map.get(ServerAccess.SINGER).toString());
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), lay3Img2, false,
						R.drawable.icon_music_default);
				map = mNewList.get(2);
				lay3special_name3.setText(map.get(ServerAccess.MUSIC_NAME)
						.toString());
				lay3countTxt3
						.setText(map.get(ServerAccess.LISTENER).toString());
				lay3playerName3
						.setText(map.get(ServerAccess.SINGER).toString());
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), lay3Img3, false,
						R.drawable.icon_music_default);
				map = mNewList.get(3);
				lay3special_name4.setText(map.get(ServerAccess.MUSIC_NAME)
						.toString());
				lay3countTxt4
						.setText(map.get(ServerAccess.LISTENER).toString());
				lay3playerName4
						.setText(map.get(ServerAccess.SINGER).toString());
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), lay3Img4, false,
						R.drawable.icon_music_default);
				map = mNewList.get(4);
				lay3special_name5.setText(map.get(ServerAccess.MUSIC_NAME)
						.toString());
				lay3countTxt5
						.setText(map.get(ServerAccess.LISTENER).toString());
				lay3playerName5
						.setText(map.get(ServerAccess.SINGER).toString());
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), lay3Img5, false,
						R.drawable.icon_music_default);

			
				updateArrayList();
			

			
				map = new HashMap<String, Object>();
				map = mHotList.get(0);
				lay4MusicName1.setText(map.get(ServerAccess.MUSIC).toString());
				lay4countTxt1
						.setText(map.get(ServerAccess.LISTENER).toString());
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), lay4Img1, false,
						R.drawable.icon_music_default);

				map = mHotList.get(1);
				lay4MusicName2.setText(map.get(ServerAccess.MUSIC).toString());
				lay4countTxt2
						.setText(map.get(ServerAccess.LISTENER).toString());
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), lay4Img2, false,
						R.drawable.icon_music_default);

				map = mHotList.get(2);
				lay4MusicName3.setText(map.get(ServerAccess.MUSIC).toString());
				lay4countTxt3
						.setText(map.get(ServerAccess.LISTENER).toString());
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), lay4Img3, false,
						R.drawable.icon_music_default);

				map = mHotList.get(3);
				lay4MusicName4.setText(map.get(ServerAccess.MUSIC).toString());
				lay4countTxt4
						.setText(map.get(ServerAccess.LISTENER).toString());
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), lay4Img4, false,
						R.drawable.icon_music_default);

				map = mHotList.get(4);
				lay4MusicName5.setText(map.get(ServerAccess.MUSIC).toString());
				lay4countTxt5
						.setText(map.get(ServerAccess.LISTENER).toString());
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), lay4Img5, false,
						R.drawable.icon_music_default);

				map = mHotList.get(5);
				lay4MusicName6.setText(map.get(ServerAccess.MUSIC).toString());
				lay4countTxt6
						.setText(map.get(ServerAccess.LISTENER).toString());
				mImageLoader.DisplayImage(map.get(ServerAccess.ICON_URL)
						.toString(), lay4Img6, false,
						R.drawable.icon_music_default);
			}
				break;
			default:
				break;
			}
			super.handleMessage(msg);
		}
	};

	// 创建多线程获取数据
	protected Runnable runnable = new Runnable() {

		@Override
		public void run() {
			// TODO Auto-generated method stub
			try {
				

				mList = new ArrayList<HashMap<String,Object>>();
				mMusicList = new ArrayList<HashMap<String,Object>>();
				mAlbumList = new ArrayList<HashMap<String,Object>>();
				mNewList = new ArrayList<HashMap<String,Object>>();
				mHotList = new ArrayList<HashMap<String,Object>>();
				getListAtFirstPage();
				sendMessage(UPDATE_DATA);
				
				String key5[] = new String[] { ServerAccess.ID,
							ServerAccess.MID, ServerAccess.STATE,
							ServerAccess.ICON_URL, ServerAccess.CODE };
					mAvdList = new ArrayList<HashMap<String, Object>>();
					mAvdList = serverAccess.getListAdv("1",key5 );
					sendMessage(UPDATE_FIVE);
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}
		}
	};

	// 发送消息到Handler
	private void sendMessage(int what) {
		Message msg = new Message();
		msg.what = what;
		handler.sendMessage(msg);
	}

	// 若在线程中更新与Adapter的动态数组将会产生致命错误。
	private void updateArrayList() {

		if (mPlayerList != null) {
			int count = mList.size();
			for (int i = 0; i < count; i++) {
				mPlayerList.add(mList.get(i));
			}
		}

		mAdapter.notifyDataSetChanged();
	}
	

	
	// 获取首页专辑推荐
		public void getListAtFirstPage() throws JSONException {
			String jsonString = mPostAccess.sendPostData(new String[] { ServerAccess.INDEX },
					new String[] { "0" }, GlobalValue.getUrl(ServerAccess.MAIN));
			
			JSONArray jsonArray1 = new JSONObject(jsonString).getJSONArray(ServerAccess.SINGER);
			JSONArray jsonArray2 = new JSONObject(jsonString).getJSONArray(ServerAccess.MUSIC);
			JSONArray jsonArray3 = new JSONObject(jsonString).getJSONArray(ServerAccess.ALBUM);
			JSONArray jsonArray4 = new JSONObject(jsonString).getJSONArray(ServerAccess.NEW);
			JSONArray jsonArray5 = new JSONObject(jsonString).getJSONArray(ServerAccess.GROUP);
			
			
			for (int i = 0; i < jsonArray1.length(); i++) {
				HashMap<String, Object> map = new HashMap<String, Object>();
				JSONObject jsonObject = ((JSONObject) jsonArray1.opt(i));
				for (int j = 0; j < keyPlayer.length; j++) {
						map.put(keyPlayer[j], jsonObject.getString(keyPlayer[j]));

				}
				mList.add(map);
			}
			
			for (int i = 0; i < jsonArray2.length(); i++) {
				HashMap<String, Object> map = new HashMap<String, Object>();
				JSONObject jsonObject = ((JSONObject) jsonArray2.opt(i));
				for (int j = 0; j < keyMusci.length; j++) {
					if(keyMusci[j].equals(ServerAccess.ALBUM)){
						map.put(keyMusci[j], "");
					}
					else{
						map.put(keyMusci[j], jsonObject.getString(keyMusci[j]));
					}
					

				}
				mMusicList.add(map);
			}
			
			

			for (int i = 0; i < jsonArray3.length(); i++) {
				HashMap<String, Object> map = new HashMap<String, Object>();
				JSONObject jsonObject = ((JSONObject) jsonArray3.opt(i));
				for (int j = 0; j < keyAlbum.length; j++) {
						map.put(keyAlbum[j], jsonObject.getString(keyAlbum[j]));
				}
				mAlbumList.add(map);
			}
			
			
			for (int i = 0; i < jsonArray4.length(); i++) {
				HashMap<String, Object> map = new HashMap<String, Object>();
				JSONObject jsonObject = ((JSONObject) jsonArray4.opt(i));
				for (int j = 0; j < keyNew.length; j++) {
					if(keyNew[j].equals(ServerAccess.ALBUM)){
						map.put(keyNew[j], "");
					}
					else{
						map.put(keyNew[j], jsonObject.getString(keyNew[j]));
					}

				}
				mNewList.add(map);
			}
			
			
			for (int i = 0; i < jsonArray5.length(); i++) {
				HashMap<String, Object> map = new HashMap<String, Object>();
				JSONObject jsonObject = ((JSONObject) jsonArray5.opt(i));
				for (int j = 0; j < keyGruop.length; j++) {
						map.put(keyGruop[j], jsonObject.getString(keyGruop[j]));

				}
				mHotList.add(map);
			}
		}
}
